package com.example.micrauth.domain.vo;

import com.example.common.enums.RCode;
import lombok.Getter;
import lombok.Setter;

/**
 * @description: 统一放回结果
 * @author: uu
 * @date: 2024/2/28 0:14
 * @version: 1.0
 */
@Getter
@Setter
public class RespResult {
    private int code;
    private String msg;
    private Object data;

    public RespResult Data(Object data){
        this.setData(data);
        return this;
    }
    public RespResult Msg(String msg) {
        this.msg = msg;
        return this;
    }
    public RespResult Code(Integer code) {
        this.code = code;
        return this;
    }

    public static RespResult success() {
        RespResult result = new RespResult();
        result.setRCode(RCode.SUCCESS);
        return result;
    }
    public static RespResult fail(){
        RespResult result = new RespResult();
        result.setRCode(RCode.UNKOWN);
        return result;
    }

    public void setRCode(RCode rCode) {
        this.code = rCode.getCode();
        this.msg = rCode.getText();
    }

}
